home *** CD-ROM | disk | FTP | other *** search
- @if-using not(ocl-file-search-enter)
- @use (ocl-file-search-enter)
- ;OCL{{{}}}
- ;OCL{{{ reference description
- @if-using ( FUN-REFERENCE ) ; 1 ;
- This library defines a variant of enter fold, which tries to follow include
- statements, if used on normal text.
- @fi
- ;OCL}}}
- ;OCL{{{ libs
- @use ( language-ocl )
- @if-using not(ocl-file-userlang) @lib userlang @fi
- @if-using not(ocl-file-next-char) @lib next-char @fi
- ;OCL}}}
- ;OCL{{{ search-and-enter-fold
- ;OCL{{{ reference
- @if-using ( FUN-REFERENCE ) ; 2 ; search-and-enter-fold-called
- ;OCL{{{ search-and-enter-fold
- If used on a text-line, the command tries to follow a include statement on
- that line. If this failes, the normal enter-fold action is activated (prompt
- for filename). If the save of a chnaged file failes, the search for the
- include file is omitted.
-
- @ref-start-tbl Language 8 Statement 32
- all @@ #include "filename"
- all @@ #include <filename>
- OCL @@ @lib filename
- OCL @@ @include filename
- Roff @@ .so filename
- @ref-end-tbl
-
- The files are searched in the `:'-separated directory-list, given by the
- environement variable ORIGAMILIBPATH (default is `/usr/include').
- ;OCL}}}
- @fi
- ;OCL}}}
- ( history e-l-f-name )
- ( history e-l-f-path )
- ( defvar ( e-l-f-c e-l-f-x ) )
- ( deffun search-and-enter-fold
- ( set e-l-f-x store-pos
- if
- ;OCL{{{ line matches a iclude statement
- and
- ( test-text
- not(in-prompt)
- pre
- ( if test-file-changed ( save-file ) fi )
- not(test-file-changed)
- or
- (
- ;OCL{{{ ocl: @lib and @include
- and
- ( eval ( test-language-ocl )
- or
- ( test-str "@lib
- test-str "@include
- pre
- ( screen-off beginning-of-line screen-on )
- or
- ( test-str "@lib
- test-str "@include
- )
- )
- )
- ;OCL}}}
- ;OCL{{{ all: #include
- and
- ( pre
- ( screen-off beginning-of-line screen-on )
- test-char "#
- pre
- ( screen-off next-non-space-on-line screen-on )
- test-str "include
- )
- ;OCL}}}
- ;OCL{{{ roff: #include
- and
- ( test-language Roff
- pre
- ( screen-off goto 1 screen-on )
- test-str ".so
- )
- ;OCL}}}
- )
- )
- ;OCL}}}
- ;OCL{{{ try to enter given file, return from macro on success
- ( screen-off
- ;OCL{{{ destination file into e-l-f-name
- history-edit-line e-l-f-name ()
- ;OCL{{{ skip command and limiting spaces
- while not(test-char " )
- ( forward-character )
- while and(test-char " not(test-end-line))
- ( forward-character )
- ;OCL}}}
- ;OCL{{{ delete in front of command
- while not(test-begin-line)
- ( delete-previous-character )
- ;OCL}}}
- ;OCL{{{ delete end of filename
- case
- ( test-char "" ( set e-l-f-c "" raw-delete-character ) )
- ( test-char "< ( set e-l-f-c "> raw-delete-character ) )
- default
- ( set e-l-f-c " )
- esac
- while and(not(test-char e-l-f-c ) not(test-end-line))
- ( forward-character )
- delete-to-end-of-line
- ;OCL}}}
- newline-and-indent
- ;OCL}}}
- ;OCL{{{ library path string to e-l-f-path
- history-edit e-l-f-path ()
- getenv "ORIGAMILIBPATH
- if test-begin-line
- ( "/usr/include:fun )
- fi
- newline-and-indent
- ;OCL}}}
- ;OCL{{{ enter the file, without any library path first
- end-of-line
- enter-fold
- get-history e-l-f-name 0
- newline-and-indent
- ;OCL}}}
- set e-l-f-x 0
- do
- ( case
- ;OCL{{{ not line 1 or not bottom -> file found
- ( or(not(test-bottom) >(store-line 1))
- ( change-buffername
- previous-line
- newline-and-indent
- beginning-of-fold
- next-line
- goto 1
- screen-on
- redraw-display
- return-from-macro
- )
- )
- ;OCL}}}
- ;OCL{{{ e-l-f-x set -> last file tried -> break from loop
- ( e-l-f-x ( set e-l-f-x 1 ) )
- ;OCL}}}
- default
- ( insert-file
- ;OCL{{{ next-file-name
- ;OCL{{{ get path
- get-history e-l-f-path 0
- beginning-of-line
- while and(not(test-end-line) not(test-char ": ))
- ( forward-character )
- delete-to-end-of-line
- if not(test-begin-line) ( insert-ascii path-separator ) fi
- ;OCL}}}
- get-history e-l-f-name 0
- newline-and-indent
- ;OCL}}}
- set-file-unchanged
- ;OCL{{{ cut path element, maybe mark last try
- history-edit e-l-f-path ()
- previous-line
- beginning-of-line
- while and(not(test-char ": ) not(test-end-line))
- ( forward-character
- delete-previous-character
- )
- if not(test-end-line)
- ( forward-character
- delete-previous-character
- )
- fi
- if test-end-line
- ( set e-l-f-x -1 )
- fi
- newline-and-indent
- ;OCL}}}
- )
- esac
- )
- while <=(e-l-f-x 0)
- exit-fold
- screen-on
- redraw-display
- )
- ;OCL}}}
- fi
- goto e-l-f-x
- refresh-line
- enter-fold
- )
- )
- ( undeclare ( e-l-f-c e-l-f-x ) )
- ;OCL}}}
- @fi
-